package expe.four;

import java.util.Scanner;

public class Rg7206 {
    public static void main(String[] args) {
        String str, a;
        Scanner scanner = new Scanner(System.in);
        str = scanner.next();
        a = scanner.next();
        System.out.println(str.replace(a, ""));
        StringBuffer tmp = new StringBuffer();
        tmp.append(str.replace(a, ""));
        System.out.println(tmp.reverse());
    }
}
